# Build stage
FROM rust:1.75 as builder

WORKDIR /app
COPY . .

# Build the project
RUN cargo build --release

# Runtime stage
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y \
    ca-certificates \
    libsqlite3-0 \
    && rm -rf /var/lib/apt/lists/*

# Copy binary
COPY --from=builder /app/target/release/hysteria /usr/local/bin/hysteria

# Copy web files (if built)
COPY --from=builder /app/web/dist /usr/share/hysteria/web

# Create directories
RUN mkdir -p /etc/hysteria /var/lib/hysteria

# Expose ports
EXPOSE 443/udp 8080

# Default command
CMD ["hysteria", "server", "-c", "/etc/hysteria/server.yaml"]
